<template>
  <el-select v-model="brand" :value="brand" :placeholder="placeholder.value"  @change="handleBrandChange($event)" clearable>
    <el-option v-for="it in brandList" :key="it.id" :value="it.id" :label="it.name" />
  </el-select>
</template>

<script setup>
import { allBrand } from "@/api/pms/brand";

const { proxy } = getCurrentInstance();
const brandList = ref([]);


const props = defineProps({
  modelValue: [String, Object, Array],
  /**输入框内部的文字 */
  placeholder: {
    type: String,
    default: '请选择品牌'
  }
})
const brand = toRef(props, 'modelValue');

const emit = defineEmits(['update:modelValue']);

function initHandle() {
  allBrand().then(response => {
    brandList.value = response.data
  })

}

function handleBrandChange (id, name) {
  console.log(id, name)
  emit('update:modelValue', id)
}

initHandle();
</script>

